package com.cn.lp.export.plugin.common.log;

import com.cn.lp.export.log.LocalLogger;
import com.cn.lp.export.log.LogHandler;
import org.apache.maven.plugin.logging.Log;
import org.slf4j.event.Level;


/** 插件日志 */
public class MavenLocalLogger implements LocalLogger {

    private Log logger;

    public MavenLocalLogger() {

    }

    public MavenLocalLogger(Log logger) {
        this.logger = logger;
    }

    @Override
    public boolean isDebugEnabled() {
        return logger.isDebugEnabled() && LogHandler.getLogLevel().toInt() <= Level.DEBUG.toInt();
    }

    @Override
    public void debug(String var1) {
        if(isDebugEnabled()) {
            logger.debug(var1);
        }
    }

    @Override
    public void debug(String var1, Throwable var2) {
        if(isDebugEnabled()) {
            logger.debug(var1, var2);
        }
    }

    @Override
    public boolean isInfoEnabled() {
        return logger.isInfoEnabled() && LogHandler.getLogLevel().toInt() <= Level.INFO.toInt();
    }

    @Override
    public void info(String var1) {
        if(isInfoEnabled()) {
            logger.info(var1);
        }
    }

    @Override
    public void info(String var1, Throwable var2) {
        if(isInfoEnabled()) {
            logger.info(var1, var2);
        }
    }

    @Override
    public boolean isWarnEnabled() {
        return logger.isWarnEnabled() && LogHandler.getLogLevel().toInt() <= Level.WARN.toInt();
    }

    @Override
    public void warn(String var1) {
        if(isInfoEnabled()) {
            logger.warn(var1);
        }
    }

    @Override
    public void warn(String var1, Throwable var2) {
        if(isInfoEnabled()) {
            logger.warn(var1, var2);
        }
    }

    @Override
    public boolean isErrorEnabled() {
        return logger.isErrorEnabled() && LogHandler.getLogLevel().toInt() <= Level.ERROR.toInt();
    }

    @Override
    public void error(String var1) {
        if(isInfoEnabled()) {
            logger.error(var1);
        }
    }

    @Override
    public void error(String var1, Throwable var2) {
        if(isInfoEnabled()) {
            logger.error(var1, var2);
        }
    }

}
